package com.jy.app.lib.net;

import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

import okhttp3.Dns;

public class ApiDns implements Dns {
    @Override
    public List<InetAddress> lookup(String hostname) throws UnknownHostException {
        List<InetAddress> mInetAddressesList = new ArrayList<>();
        try {
            InetAddress[] mInetAddresses = InetAddress.getAllByName(hostname);
            for (InetAddress address : mInetAddresses) {
                if (address instanceof Inet4Address) {
                    mInetAddressesList.add(0, address);
                } else {
                    mInetAddressesList.add(address);
                }
            }
        } catch (NullPointerException var4) {
        }
        return mInetAddressesList;
    }
}
